//
//  WKHotCell.m
//  V-Learn
//
//  Created by Apple on 2019/4/3.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "WKHotCell.h"

@implementation WKHotCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.followBnt.layer.cornerRadius = 12*ScaleX;
    self.followBnt.layer.masksToBounds = YES;
    
    self.logo.layer.cornerRadius = 22.5*ScaleX;
    self.logo.layer.masksToBounds = YES;
    [self.zanBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -3, 0, 0)];
    [self.zanBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 3, 0, 0)];
    UIButton *palyBtn = [[UIButton alloc] init];
    self.palyBtn = palyBtn;
    [palyBtn setImage:[UIImage imageNamed:@"play"] forState:UIControlStateNormal];
    [self.contentView addSubview:palyBtn];
    
    [palyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.imgView);
        make.centerY.mas_equalTo(self.imgView);
        make.size.mas_equalTo(CGSizeMake(45*ScaleX, 45*ScaleX));
    }];
    
    self.nameLab.textColor = rgb(51,51,51);
    self.nameLab.font = [UIFont systemFontOfSize:15*ScaleX];
    self.timeLab.textColor = rgb(102,102,102);
    self.timeLab.font = [UIFont systemFontOfSize:12*ScaleX];
    
    self.contentLab.textColor = rgb(51,51,51);
    self.contentLab.font = [UIFont systemFontOfSize:15*ScaleX];
    
    self.detailLab.textColor = rgb(102,102,102);
    self.detailLab.font = [UIFont systemFontOfSize:15*ScaleX];
    
    self.titleLab.textColor = rgb(102,102,102);
    self.titleLab.font = [UIFont systemFontOfSize:14*ScaleX];
//    self.zanBtn.backgroundColor = [UIColor redColor];
//    self.contentView.backgroundColor = [UIColor orangeColor];
//    self.backgroundColor = [UIColor redColor];
    [self.zanBtn remakeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-10*ScaleX);
        make.right.mas_equalTo(-10*ScaleX);
        make.size.mas_equalTo(CGSizeMake(64*ScaleX, 24*ScaleX));
    }];
    
    UIImageView *vipImageV = [[UIImageView alloc]init];
    vipImageV.image = [UIImage imageNamed:@"wk_vip"];
    vipImageV.contentMode = UIViewContentModeScaleAspectFill;
    vipImageV.clipsToBounds = YES;
    _vipImageV = vipImageV;
    [self.contentView addSubview:vipImageV];
    vipImageV.userInteractionEnabled = NO;
    vipImageV.layer.cornerRadius = 7.5*ScaleX;
    vipImageV.layer.masksToBounds = YES;
    [vipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.logo).offset(0);
        make.size.mas_equalTo(CGSizeMake(15*ScaleX, 15*ScaleX));
        make.bottom.mas_equalTo(self.logo);
    }];

//    self.zanButton = [[UIButton alloc] init];
//    self.zanButton.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:self.zanButton];
//    [self.zanButton setTitle:@"0" forState:UIControlStateNormal];
//    [self.zanButton setTitleColor:rgb(102,102,102) forState:UIControlStateNormal];
////
//    [self.zanButton setImage:LBImage(@"wk_unFabulous") forState:UIControlStateNormal];
//
//    self.zanButton.titleLabel.font = LBFont(12);
//    [self.zanButton makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(-10);
////        make.centerY.mas_equalTo(bottomView);
//        make.bottom.mas_equalTo(-10);
//        make.size.mas_equalTo(CGSizeMake(60, 24));
//    }];
//    [self.zanButton setImageEdgeInsets:UIEdgeInsetsMake(0, -3, 0, 0)];
//    [self.zanButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 3, 0, 0)];
}
- (void)setModel:(WKHotmenModel *)model{
    _model = model;
    
//    NSString *isVip = [UserModel getUserModel].isVip;
    if ([model.isVip integerValue]==1) {
        _vipImageV.hidden = NO;
    }else{
        _vipImageV.hidden = YES;
    }
    NSString *urlString = [NSString stringWithFormat:@"%@%@",Public_URL,model.headImg];
    [self.logo sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"logo"]];
    self.timeLab.text = [model.clockDate substringToIndex:10];
    self.nameLab.text = model.username;
    self.contentLab.text = model.clockTitle;
    self.detailLab.text = model.clockOrtherTitle;
    if ([model.fileType isEqualToString:@"2"]) {
        self.palyBtn.hidden = YES;
    }else{
        self.palyBtn.hidden = YES;
    }
    if (model.clockInfoVOList.count>0) {
        //底部描述
        WKHotclockInfoVOListModel *model2 = model.clockInfoVOList[0];
        self.titleLab.text = model2.infoContent;
    }
    if ([model.isAtten isEqualToString:@"1"]) {
        [self.followBnt setTitle:@"取消关注" forState:UIControlStateNormal];
        //        [self.followBnt setTitleColor:rgb(153,153,153) forState:UIControlStateNormal]
    }else{
        [self.followBnt setTitle:@"关注" forState:UIControlStateNormal];
    }
    if ([model.isPrase isEqualToString:@"1"]) {
        [self.zanBtn setImage:[UIImage imageNamed:@"wk_Fabulous"] forState:UIControlStateNormal];
    }else{
        [self.zanBtn setImage:[UIImage imageNamed:@"wk_unFabulous"] forState:UIControlStateNormal];
    }
    [self.zanBtn setTitle:model.praiseNum forState:UIControlStateNormal];
    
}
- (void)setFollowModel:(WKHotmenModel *)followModel{
    _followModel = followModel;
    
//    NSString *isVip = [UserModel getUserModel].isVip;
    if ([followModel.isVip integerValue]==1) {
        _vipImageV.hidden = NO;
    }else{
        _vipImageV.hidden = YES;
    }
    NSString *urlString = [NSString stringWithFormat:@"%@%@",Public_URL,followModel.headImg];
    [self.logo sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"logo"]];
    self.timeLab.text = [followModel.clockDate substringToIndex:10];
    self.nameLab.text = followModel.username;
    self.contentLab.text = followModel.clockTitle;
    self.detailLab.text = followModel.clockOrtherTitle;
    if (followModel.clockInfoVOList.count>0) {
        WKHotclockInfoVOListModel *model2 = followModel.clockInfoVOList[0];
        self.titleLab.text = model2.infoContent;
        
    }
    if ([followModel.isPrase isEqualToString:@"1"]) {
        [self.zanBtn setImage:[UIImage imageNamed:@"wk_Fabulous"] forState:UIControlStateNormal];
    }else{
        [self.zanBtn setImage:[UIImage imageNamed:@"wk_unFabulous"] forState:UIControlStateNormal];
    }
    [self.zanBtn setTitle:followModel.praiseNum forState:UIControlStateNormal];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
